using System.Collections.Generic;
using System.Threading.Tasks;
using Comteck.Dto.Orders;
using Comteck.Winforms.Data;

namespace Comteck.Winforms.Infrastructure {
  /// <summary>
  /// 
  /// </summary>
  public static partial class BindHelper {

    /// <summary>
    /// 自提点类型
    /// </summary>
    /// <param name="control"></param>
    /// <param name="editValue"></param>
    public static async Task BindSelfOrgTag(object control, object editValue = null, List<SelfOrgTagDto> datasource = null) {
      var options = new BindHelperOption() {
        DisplayMember = nameof(SelfOrgTagDto.Name),
        ValueMember = nameof(SelfOrgTagDto.Id),
        EditValue = editValue,
        BindColumnOptions = new List<BindColumnOption>() {
          new BindColumnOption() { Caption = "自提点标签编号", Width = 60, FieldName = nameof(SelfOrgTagDto.Id) },
          new BindColumnOption() { Caption = "自提点标签名称", Width = 150, FieldName = nameof(SelfOrgTagDto.Name) },
        }
      };

      if (datasource == null) {
        datasource = await ServerDbDataHelper.GetAllSelfOrgTagAsync();
      }
      Bind(control, options, datasource);
    }

  }
}
